<?php
/**
 * Created by PhpStorm.
 * User: stupboy
 * Date: 2018/6/7
 * Time: 9:19
 * Mail:87658989@qq.com
 */

namespace app\adminapi\validate;

use app\base\validate\BaseValidate;

class Driver extends BaseValidate
{
    protected $rule = [
        'driver_id|司机id' => 'require',
        'user_id|用户id' => 'require|min:0',
        'company_id|单位id' => 'require',
        'name|司机姓名' => 'require',
        'id_card|身份证号码' => 'require',
        'age|年龄' => 'number',
        'birthday|出生年月' => 'require|date',
        'sex|性别' => 'require|number|in:1,2',
        'phone|手机' => 'require|number|length:11',
        'add|住址' => 'length:2,100',
        'driving_age' => 'number|min:0',
        'original_position' => 'chs',
        'language' => 'require',
        'head_img' => 'imgExist',
        'half_body_img' => 'imgExist',
        'body_img' => 'imgExist',
        'insurance_img' => 'imgExist',
        'contract_img' => 'imgExist',
        'id_img' => 'imgExist',
        'id_img_back' => 'imgExist',
        'driver_license_img' => 'imgExist',
        'driver_license_img_back' => 'imgExist',
        'residence_permit_img' => 'imgExist',
        'bank_card' => 'length:10,30|number',
        'wechat' => 'length:2,50',
        'alipay' => 'length:2,50',
        'work_state' => 'number',
        'register_time' => 'date',
        'driver_no' => 'length:2,50',
        'bank' => 'length:2,50|chs',
        'state' => 'number',
        'edit_time' => 'date',
        'driver_ids' => 'require'
    ];

    protected $message = [
        'body_img.imgExist' => '不存在',
        'language.in' => '语言必须为以下其中一种 1:"普通话",2:"闽南话",3:"广东话",4:"英语",5:"日语",6:"韩语"'
    ];

    protected $default = [
        'state'=>1,
        'work_state'=>4
    ];

    protected $scene = [
        'add'=>[
            'user_id','company_id','name','id_card','age','birthday','sex','phone','add','driving_age','original_position','language','head_img','half_body_img','body_img','insurance_img','contract_img','id_img','id_img_back','driver_license_img','driver_license_img_back','residence_permit_img','bank_card','wechat','alipay','work_state','register_time','driver_no','bank','state','edit_time'
        ],
        'edit'  =>[
            'driver_id','user_id','company_id','name','id_card','age','birthday','sex','phone','add','driving_age','original_position','language','head_img','half_body_img','body_img','insurance_img','contract_img','id_img','id_img_back','driver_license_img','driver_license_img_back','residence_permit_img','bank_card','wechat','alipay','work_state','register_time','driver_no','bank','state','edit_time'
        ],
        'delete'=>[
            'driver_ids'
        ],
    ];
}